Removed all unnecessary imports.
[f432xdd.git] / java / Graph Editor / src / controllers / actions / Rename.java
blob8efedc623df441dd8d1bb772abfb69b55c8c8c70
1 package controllers.actions;
3 import javax.swing.undo.AbstractUndoableEdit;
4 import models.GraphVertex;
5 import controllers.*;
7 public class Rename extends AbstractUndoableEdit {
8 private static final long serialVersionUID = -7929100929760152271L;
9 private GraphVertex o;
10 private String savedName;
11 private int originalWidth;
12 private SelectionController selectionController;
13 public Rename(String name, SelectionController selectionController)
15 this.selectionController = selectionController;
16 this.savedName = name;
17 this.o = selectionController.getSelectedVertex();
18 originalWidth = o.getWidth();
19 this.redo();
22 public void redo()
24 System.out.println("REDO - " + o.getName() + " -> " + savedName);
25 int width = 20 + this.selectionController.getPanel().getDrawTextWidth(savedName);
26 if(width > o.getWidth())
27 o.setWidth(width);
29 String objectName = o.getName();
30 o.setName(savedName);
31 savedName = objectName;
34 public void undo()
36 String objectName = o.getName();
37 o.setName(savedName);
38 o.setWidth(originalWidth);
39 savedName = objectName;